/*
 * @Author: your name
 * @Date: 2021-01-06 11:41:34
 * @LastEditTime: 2021-01-23 21:46:50
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \express-seed\dao\imgDao.js
 */
const { querySql } = require('../db')
module.exports = {
    // 查询图片列表
    async selectImgsDao() {
        const sql = `select * from imgs`
        return await querySql(sql)
    },
    //添加图片列表
    async addImgDao(imgsInfo) {
        let insertStr = ''
        imgsInfo.forEach(item => {
            insertStr += `('${item.name}','${item.imgPath}'),`
        })
        let sql = `insert into imgs (img_name, img_path) values ` + insertStr
        sql = sql.substr(0, sql.length - 1)
        return await querySql(sql)
    },
    //根据id删除图片
    async delImgDao(img_id) {
        const sql = `delete from imgs where id='${img_id}'`
        return await querySql(sql)
    }
}